<?php
 class Configs extends CI_Model{
    function __construct(){
        parent::__construct();
    }
    
     /** 
     * Insert data for config
     * @author tien.nguyen
     */
    public function getList(){
        $query = $this->db->get('configs');
        $res = $query->result_array();
        return $res;
    }
    
    /**
     * edit function in config
     * @author tien.nguyen
     */
    public function edit($data, $configId){
        $data = $this->_convertData($data);
        return $this->db->update('configs', $data, array('ConfigId' => $configId));
    }
    
    private function _convertData($data){
        $res = array();
        $arr = array('ConfigId', 'ConfigCode', 'ConfigName', 'ConfigValue', 'ConfigDescription');
        foreach($arr as $item){
            if(isset($data[$item])){
                $res[$item] = $data[$item];
            }
        }
        return $res;
    }
 }
?>